/*
 * @lc app=leetcode.cn id=506 lang=rust
 *
 * [506] 相对名次
 */

// @lc code=start
impl Solution {
    pub fn find_relative_ranks(score: Vec<i32>) -> Vec<String> {
        use std::collections::HashMap;
        let mut ret = vec![];

        let mut vec = score.clone();
        vec.sort();

        let mut map = HashMap::new();
        let mut i = score.len();

        if vec.len() > 3{
            for j in 0..vec.len()-3 {
                map.insert(vec[j], String::from(i.to_string()));
                i -= 1;
            }
        }

        
        map.insert(vec[vec.len() - 1], String::from("Gold Medal"));
        if(vec.len() > 1)
        {
            map.insert(vec[vec.len() - 2], String::from("Silver Medal"));
        }
        if(vec.len() > 2)
        {
            map.insert(vec[vec.len() - 3], String::from("Bronze Medal"));
        }


        for j in score.iter() {
            ret.push(String::from(map.get(j).unwrap()));
        }

        return ret;
    }
}
// @lc code=end

